package library;

public class Book {
    //所有属性设置为private。
    private String name;
    private String author;
    private double price;
    private String type;
    private boolean isBorrowed;

    public Book(String name, String author, double price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
        this.isBorrowed = false;
    }
//private 所以使用getter和setter方法。
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price * 0.8;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }

    @Override
    public String toString() {
//        return "Book {" +
//                "name='" + name + '\'' +
//                ", author='" + author + '\'' +
//                ", price=" + price +
//                ", type='" + type + '\'' +
//                ", isBorrowed=" + isBorrowed +
//                '}';
        return "[" + name + "," + author + "," + price + "," + type + "," + (isBorrowed? "已借出" : "未借出") + "]";
    }
}
